﻿#define _CRT_SECURE_NO_WARNINGS 1
# include<stdio.h>
#include <string.h>
#include<Windows.h>
int main() {             
	              ////练习1：多个字符从两端移动，向中间汇聚

	//char arr1[] = "*******************";
	//char arr2[] = "welcome to my world";
	//int left = 0;
	//size_t right = strlen(arr2)-1; // strlen()返回值也是size_t
	//int i = 0;
	//while (left <= right)
	//{
	//	arr1[left] = arr2[left];
	//	arr1[right] = arr2[right];
	//	printf("%s\n", arr1);
	//	left++;
	//	right--;
	//	Sleep(500);
	//	system("cls");
	//}
	//printf("%s", arr2);


	             //练习2：⼆分查找（有序）
	int arr1[] = {0,1,2,3,4,5,6,7,8,9,10 };
	int k = 0;
	scanf("%d", &k);
	int left = 0;
	int right = sizeof(arr1) / sizeof(arr1[0])-1;
	while (left<=right)
	{
		int mid= (left + right) / 2;
		if (k > arr1[mid]) {
			left = mid + 1;
			
		}
		else if (k < arr1[mid])
		{
			right = mid - 1;
		}
		else
		{
			printf("找到了它的位置下标为%d" , mid);
			break;
		}
	}
	if (left > right)
		printf("在数组中找不到%d", k);

	return 0;
}